package com.caine.androidtask.ls19;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.StatFs;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.caine.androidtask.R;
import com.caine.androidtask.ls14.Utils;

public class DataContentActivity extends Activity implements OnClickListener {
	
	
	public Button btn_call_01;
	public Button btn_ls19_webbrow;
	public Button btn_ls19_sent_sms_01;
	public Button btn_ls19_contact;
	long abc;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.caine_ls19);
		init();
	}
	
	void init(){
		btn_call_01 = (Button) findViewById(R.id.ls19_call_01);
		btn_ls19_webbrow = (Button) findViewById(R.id.ls19_webbrow);
		btn_ls19_sent_sms_01 = (Button) findViewById(R.id.ls19_sent_sms_01);
		btn_ls19_contact = (Button) findViewById(R.id.ls19_contact);
		
		
		// add listener
		btn_call_01.setOnClickListener(this);
		btn_ls19_webbrow.setOnClickListener(this);
		btn_ls19_sent_sms_01.setOnClickListener(this);
		btn_ls19_contact.setOnClickListener(this);
		
		 RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
 			     LayoutParams.WRAP_CONTENT);
 	         lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
 	        lp.topMargin = 100;
 	       lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
	         lp.leftMargin = 20;
	         lp.rightMargin = 20;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		//Intent intent = new Intent();
		System.err.println();
		switch (v.getId()) { 
		case R.id.ls19_call_01 :
			abc = 524288L;
			Intent intent_call_01 = new Intent(Intent.ACTION_CALL,Uri.parse("tel:112"));
			intent_call_01.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			startActivity(intent_call_01);
			StatFs fs  = new StatFs("/data");
			Log.e(Utils.TAG, fs.getBlockCount()+":"+fs.getBlockSize()+" = "+fs.getBlockCount()*fs.getBlockSize()+"");
			Log.e(Utils.TAG,android.text.format.Formatter.formatShortFileSize(this,fs.getBlockSize()));
			break;
		case R.id.ls19_webbrow :
			Intent intent_webbrow = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com/"));
			intent_webbrow.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			startActivity(intent_webbrow);
			break;  
		case R.id.ls19_sent_sms_01 :
			Intent intent_sms_01 = new Intent();
			intent_sms_01.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			intent_sms_01.setAction(Intent.ACTION_VIEW); 
			intent_sms_01.putExtra("address", "10010");  
			intent_sms_01.putExtra("sms_body", "I am caine!!!");  
			intent_sms_01.setType("vnd.android-dir/mms-sms");   
			startActivity(intent_sms_01);
			break;
		case R.id.ls19_contact :
			Intent intent_contact = new Intent();
			intent_contact.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			intent_contact.setAction("com.android.contacts.action.LIST_CONTACTS");
            startActivity(intent_contact);
            break;
		}
		
	}
}
